package edu.uwm.RobberKnight.View;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics; 

/*
 * Help information for the Robber Knights game.
 */
public class HelpView extends JPanel {

    private static final long serialVersionUID = -4740568034675477810L;
    private boolean close = false;
    private JTabbedPane tabbedPane;
    
    /**
     * Create the panel.
     */
    public HelpView() {
       
        tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        add(tabbedPane);
        
        
        // Tab to explain how to use GUI
        JPanel tilePanel1 = new JPanel(); 
        tabbedPane.addTab(" Using GUI ", null, tilePanel1, null);
        JTextArea textArea1 = new JTextArea(){
        	
			// Adding picture to explain how to use GUI 
			private static final long serialVersionUID = 1L;

			@Override
        	public void paintComponent(Graphics g){
        		g.drawImage(Resources.getGamePlay(),0,0, null);
        	}
        };
        tilePanel1.setPreferredSize(new Dimension(580, 450));
        tilePanel1.setLayout(new BorderLayout(0, 0));
        tilePanel1.add(textArea1);
        
        // Tab to explain Tile Types 
        JPanel panel2 = new JPanel();
        tabbedPane.addTab(" Tile Types ", null, panel2, null);
        JTextArea image2 = new JTextArea(){ 
			private static final long serialVersionUID = 1L;

			//Adding picture to explain how the Tile Types
			@Override
        	public void paintComponent(Graphics g){
        		g.drawImage(Resources.getTilesTypePic(),0,0, null);
        	}
        };
        JTextArea textArea2 = new JTextArea();
        textArea2.setText("There are a total of 96 landscape tiles available for game play; 24 for each player. The tiles are double sided. One side of each of these tiles shows one of six possible landscapes: Mountains, Lake, Plain, Castle, Village, or a Town. The other side shows the color and letter of the tile (i.e. Blue Players' tiles 'A' through 'E'. ");
        textArea2.setEditable(false);
        textArea2.setWrapStyleWord(true);
        textArea2.setLineWrap(true);
        textArea2.setFont(new Font("arial", Font.PLAIN, 13));
        panel2.setLayout(new BorderLayout(0, 0));
        panel2.add(image2, BorderLayout.CENTER);
        panel2.add(textArea2, BorderLayout.SOUTH);
        
        
        // Tab to explain Initial Player Posession 
        JPanel panel3 = new JPanel();
        tabbedPane.addTab(" Initial Posessions ", null, panel3, null);
        JTextArea image3 = new JTextArea(){ 
			private static final long serialVersionUID = 1L;

			//Adding picture to explain Initial Player Posession
			@Override
        	public void paintComponent(Graphics g){
        		g.drawImage(Resources.getInitialPosessions(),0,0, null);
        	}
        };
        JTextArea textArea3 = new JTextArea();
        textArea3.setText("Each player is assigned a color (red, yellow, green, or blue). Each player receives 24 landscape tiles and 30 knights of the corresponding color. Player has individually shuffled group of tiles. Each player has a pile of tiles face down. The tiles with the letter 'E' are placed at the bottom, then the tiles with the letter 'D', then the tiles with 'C' and finally the tiles with the letter 'B' are placed on the top of the pile. 4 'A' tiles remain to start the landscape.");
        textArea3.setEditable(false);
        textArea3.setWrapStyleWord(true);
        textArea3.setLineWrap(true);
        textArea3.setFont(new Font("arial", Font.PLAIN, 13));
        panel3.setLayout(new BorderLayout(0, 0));
        panel3.add(image3, BorderLayout.CENTER);
        panel3.add(textArea3, BorderLayout.SOUTH);

        // Tab to explain Starting Landscape 
        JPanel panel4 = new JPanel();
        tabbedPane.addTab(" Starting Landscape ", null, panel4, null);
        JTextArea image4 = new JTextArea(){ 
			private static final long serialVersionUID = 1L;

			//Adding picture to explain how the starting landscape works
			@Override
        	public void paintComponent(Graphics g){
        		g.drawImage(Resources.getLandscape(),0,0, null);
        	}
        };
        JTextArea textArea4 = new JTextArea();
        textArea4.setText("Each Player has to pick 2 out of 3 'A' tiles to start the landscape (Castle is not in play during the starting landscape). These tiles are laid together to form a 2 x N rectangle (where N is the number of total players).Size of the playing area is calculated by the number of users playing the game. For a two player game the board cannot be larger than 7 x 7 tiles. For a 3 player game the maximum size is 9 X 9 tiles and for 4 players 10 x 10 tiles.");
        textArea4.setEditable(false);
        textArea4.setWrapStyleWord(true);
        textArea4.setLineWrap(true);
        textArea4.setFont(new Font("arial", Font.PLAIN, 13));
        panel4.setLayout(new BorderLayout(0, 0));
        panel4.add(image4, BorderLayout.CENTER);
        panel4.add(textArea4, BorderLayout.SOUTH);
        
   
        // Tab to explain how regular turns work
        JPanel panel5 = new JPanel();
        tabbedPane.addTab(" Regular Turns ", null, panel5, null);
        JTextArea image5 = new JTextArea(){ 
			private static final long serialVersionUID = 1L;

			//Adding picture to explain how scoring works
			@Override
        	public void paintComponent(Graphics g){
        		g.drawImage(Resources.getRegularTurnsPic(),0,0, null);
        	}
        };
        JTextArea textArea5 = new JTextArea();
        textArea5.setText("The oldest player begins and play then continues in order of age. The player whose turn it is adds one of their two tiles from their current hand. At least one edge must border one of the tiles already laid out. To place a tile, player needs to select a tile on his current hand and click on the blinking spots in the board. The player can carry out this action a total of three times when it is their turn. If a player adds a tile that is a castle, they can play up to five knights starting on this castle.");
        textArea5.setEditable(false);
        textArea5.setWrapStyleWord(true);
        textArea5.setLineWrap(true);
        textArea5.setFont(new Font("arial", Font.PLAIN, 13));
        panel5.setLayout(new BorderLayout(0, 0));
        panel5.add(image5, BorderLayout.CENTER);
        panel5.add(textArea5, BorderLayout.SOUTH);
        
        // Tab to explain how to Place a Knight
        JPanel panel6 = new JPanel();
        tabbedPane.addTab(" Placing Knights ", null, panel6, null);
        JTextArea image6 = new JTextArea(){ 
			private static final long serialVersionUID = 1L;

			//Adding picture to explain how placing a Knight works
			@Override
        	public void paintComponent(Graphics g){
        		g.drawImage(Resources.getPlayingKnightPic(),0,0, null);
        	}
        };
        JTextArea textArea6 = new JTextArea();
        textArea6.setText("Knights are only moved immediately after being brought into play. There are restrictions on the number of knights allowed and minimum number of knights required to entire a tile. One knight is required on a plain tile. A tile with a forest on it requires 2 knights and mountain tile requires 3 knights. Knights cannot enter a tile with a lake over it. More knights can be left on a tile but never more than 4 knights on any one tile.");
        textArea6.setEditable(false);
        textArea6.setWrapStyleWord(true);
        textArea6.setLineWrap(true);
        textArea6.setFont(new Font("arial", Font.PLAIN, 13));
        panel6.setLayout(new BorderLayout(0, 0));
        panel6.add(image6, BorderLayout.CENTER);
        panel6.add(textArea6, BorderLayout.SOUTH);
        
        // Tab to explain how scoring works
        JPanel panel7 = new JPanel();
        tabbedPane.addTab(" Scoring ", null, panel7, null);
        JTextArea image7 = new JTextArea(){ 
			private static final long serialVersionUID = 1L;

			//Adding picture to explain how scoring works
			@Override
        	public void paintComponent(Graphics g){
        		g.drawImage(Resources.getScoringPic(),0,0, null);
        	}
        };
        JTextArea textArea7 = new JTextArea();
        textArea7.setText("The player whose knight is on top on the tile in question is in control and is awarded the corresponding victory points. The castle, village, and town are worth 1, 2, and 3 points respectively. Landscape tiles without buildings score no points. The player with the most points altogether wins the game. If two players have the same number of points, the player who still has the most knights in front of them is the winner. If some players are still equal, the game is declared a draw. The game is ended when all tiles have been played.");
        textArea7.setEditable(false);
        textArea7.setWrapStyleWord(true);
        textArea7.setLineWrap(true);
        textArea7.setFont(new Font("arial", Font.PLAIN, 13));
        panel7.setLayout(new BorderLayout(0, 0));
        panel7.add(image7, BorderLayout.CENTER);
        panel7.add(textArea7, BorderLayout.SOUTH);
               
    }

    public boolean isClosed() {
        return close;
    }

    public void openInst() {
        close = false;
    }
    
}
